#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int findMinArrowShots(vector<vector<int>>& p) {
    sort(p.begin(), p.end(), [](vector<int>& v1, vector<int>& v2) {
        return v1[0] < v2[0];
        });

    int ret = 1;
    int right = p[0][1];
    for (int i = 1; i < p.size(); ++i)
    {
        int a = p[i][0], b = p[i][1];
        if (a <= right)
        {
            right = min(right, b);
        }
        else
        {
            ++ret;
            right = b;
        }
    }
    return ret;
}

int main()
{
    vector<vector<int>> vv;
    vv.push_back({1,2});
    vv.push_back({2,3});
    vv.push_back({3,4});
    vv.push_back({4,5});

    findMinArrowShots(vv);

	return 0;
}